package it.dgtest.server.ibatis;

import it.dgtest.server.ibatis.mapper.ComuneMapper;
import it.dgtest.server.ibatis.mapper.ProvinciaMapper;
import it.dgtest.shared.Comune;
import it.dgtest.shared.Provincia;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.oa.gform.server.GFormConfig;
import com.oa.gform.server.ibatis.GIBatisRegistry;

public class IBatisConfig  implements ServletContextListener {
	static Log log = LogFactory.getLog(IBatisConfig.class);
	
	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		log.info("Info - Costruzione contesto di mapping.");
		GFormConfig.setIBatisUtil(new IBatisUtilImpl("ibatis.cfg.xml"));
		GIBatisRegistry.addMapping(Comune.class, ComuneMapper.class);
		GIBatisRegistry.addMapping(Provincia.class, ProvinciaMapper.class);
	}

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	
}
